{% extends "./inc/inc_baseNew.html" %} {% block content %}
<link rel="stylesheet" href="/static/admin/js/webuploader/webuploader.css" type="text/css">
<style>
	.setting .row {
		margin-top: 20px;
		margin-bottom: 20px;
	}
	.setting .row a{
		color: #40a9ff;
	}
	.tab-pane .row.align-items-center {
		/* min-height: 400px; */
	}

	.row>label:first-child {
		text-align: right;
		color: #666;
	}

	.required:before {
		content: '*';
		font-weight: 700;
		color: #f00;
		margin-right: 5px;
	}

	.setting {
		font-size: 16px;
	}

	.nav-tabs .nav-link.active {
		border-radius: 0;
		color: #fff;
		background-color: #4e9be6;
		border-color: #dee2e6;
	}
	.webuploader-pick {
		padding:10px;
	}
	div[id^="rt_rt_"] {
		left:0 !important;
	}
</style>
<section>
	<div class="container setting">
		<div class="row">
			<!-- LEFT -->
			{# include "./inc/user_left.html" #}
			<!-- RIGHT -->
			<div class="col-md-12">
				<ul class="nav nav-tabs" id="myTab" role="tablist">
					<li class="nav-item">
						<a class="nav-link " id="home-tab" data-toggle="tab" href="#home" role="tab"
							aria-controls="home" aria-selected="true">基本资料</a>
					</li>
					<li class="nav-item">
						<a class="nav-link active" id="profile-tab" data-toggle="tab" href="#profile" role="tab"
							aria-controls="profile" aria-selected="false">用户认证</a>
					</li>
					<li class="nav-item">
						<a class="nav-link" id="contact-tab" data-toggle="tab" href="#contact" role="tab"
							aria-controls="contact" aria-selected="false">修改密码</a>
					</li>
				</ul>
				<div class="tab-content" id="myTabContent">
					<div class="tab-pane fade " id="home" role="tabpanel" aria-labelledby="home-tab">
						<div class="row justify-content-center align-items-center">
							<form role="form" class="col-md-8 form-info" action="/center/seting/updateinfo" method="post" data-validate="parsley">
								<div class="form-group row ">
									<label class="col-md-4 col-form-label">会员帐号：</label>
									<label class="col-md-8 col-form-label">
										{{userInfo.username}}
										<!-- <span style="margin-left: 50px;">
																		{% if userInfo.user_active %}
																		<span style="color: green;">已激活</span>
																		{% else %}
																		<span style="color: red;">未激活</span>
																		{% endif %}
																	</span> -->
									</label>
								</div>
								<div class="form-group row">
									<label class="required col-md-4 col-form-label">昵称：</label>
									<div class="col-md-3">
										<input type="text" placeholder="昵称" class="form-control" name="nickname" value="{{userInfo.nickname}}" required>
									</div>
								</div>
								<div class="form-group row align-items-center" style="margin-bottom: 0px;">
										<label class="col-md-4 col-form-label">头像：</label>
										<input type="hidden" name="avatar" class="form-control" value="{{userInfo.avatar}}" />
										<!-- <div class="col-md-2">
											<div id="uploader-demo">
												<div id="fileList" class="uploader-list"></div>
												<div id="avatar">选择图片</div>
											</div>
										</div> -->
										{% set avatar = userInfo.avatar | strToJson %}
										<a id="avatar-view" class="col-md-3 col-form-label text-center" href="javascript:;">
												<img style="width:100%;" src="{{avatar[0] or '/static/assets_new/img/blank.png'}}">
												<div id="avatar" style="
												position: absolute;
												top: 0;
												width: 100%;
												height: 100%;
												opacity: 0;
											"></div>
										</a>
								</div>
								<div class="form-group row align-items-center" style="margin-top: 0px;margin-bottom: 5px;">
										<label class="col-md-4 col-form-label"></label>
										<label class="col-md-3 col-form-label text-center" style="font-size: 14px;">请点击图片区域添加头像</label>
								</div>
								<div class="form-group row" style="margin-top: 5px;">
									<label class="col-md-4 col-form-label"></label>
									<div class="col-md-3 col-md-offset-2 text-center">
										<button class="btn btn-primary ajax-post no-refresh" target-form="form-info"
											type="submit"><i class="fa fa-check"></i> 保存更改 </button>
									</div>
								</div>
							</form>
						</div>
					</div>
					<div class="tab-pane fade show active" id="profile" role="tabpanel" aria-labelledby="profile-tab">
						<div class="row justify-content-center align-items-center">
								{%if(userInfo.zhucestatus ==1)%}
								{% set disable = true %}
								{%else%}
								{% set disable = false %}
								{%endif%}
							<form class="form-renzheng col-8" action="/center/seting/updateinfo" method="post" data-validate="parsley">
								<input type="hidden"  name="zhucestatus" value="1" readonly>
								<div class="form-group row">
									<label class="required col-md-4 col-form-label">认证类型：</label>
									<div class="col-md-6">
										<div class="custom-control custom-radio custom-control-inline">
											<input type="radio" {%if userInfo.org_type ==1 %}checked{%endif%} id="customRadioInline1"
												class="custom-control-input col-form-label" value="1" name="org_type" required {%if disable %} disabled{%endif%}>
											<label class="custom-control-label" for="customRadioInline1">企业(个体)</label>
										</div>
										<div class="custom-control custom-radio custom-control-inline">
											<input type="radio" {%if userInfo.org_type ==0 %}checked{%endif%} id="customRadioInline2"
												class="custom-control-inpu col-form-labelt" value="0" name="org_type"  required {%if disable %} disabled{%endif%}>
											<label class="custom-control-label" for="customRadioInline2">个人</label>
										</div>
									</div>
								</div>
								<div class="form-group row">
									<label class="required col-md-4 col-form-label">姓名：</label>
									<div class="col-md-4">
										<input type="text" class="form-control" name="real_name" value="{{userInfo.real_name}}"
											placeholder="输入姓名" required {%if disable %} disabled{%endif%}>
									</div>
								</div>
								<div class="form-group row">
									<label class="required col-md-4 col-form-label">身份证号：</label>
									<div class="col-md-4">
										<input type="text" class="form-control" name="user_code" value="{{userInfo.user_code}}"
											placeholder="请输入身份证号" required {%if disable %} disabled{%endif%}>
									</div>
								</div>
								
								<div class="form-group row" {% if userInfo.org_type ==0 %} style="display: none;" {%endif%}>
									<label class="required col-md-4 col-form-label">公司名称：</label>
									<div class="col-md-8">
										<input type="text" class="form-control" name="gsmc" value="{{userInfo.gsmc}}"
											placeholder="请输入公司名称（企业）" required {%if disable %} disabled{%endif%}>
									</div>
								</div>
								<div class="form-group row align-items-center">
									<label class="required col-md-4 col-form-label">身份证正面：</label>
									<input type="hidden" name="sfzzmpic" class="form-control" required value="{{userInfo.sfzzmpic}}" required/>
									{%if(userInfo.zhucestatus!=1)%}
									<div class="col-md-2">
										<div id="uploader-demo">
											<div id="fileList" class="uploader-list"></div>
											<div id="sfzzmpic">选择图片</div>
										</div>
									</div>
									{%endif%}
									{% set sfzzmpic = userInfo.sfzzmpic | strToJson %}
									{% if( sfzzmpic.length > 0  )%}
									<a id="sfzzmpic-view" class="col-md-2 col-form-label" href="{{sfzzmpic[0]}}" data-toggle="lightbox">查看</a>
									{%else%}
									<a id="sfzzmpic-view" class="col-md-2 col-form-label" href="javascript:;" data-toggle="lightbox"></a>
									{%endif%}
								</div>
								<div class="form-group row align-items-center">
									<label class="required col-md-4 col-form-label">身份证反面：</label>
									<input type="hidden" name="sfzfmpic" class="form-control" required value="{{userInfo.sfzfmpic}}" required/>
									{%if(userInfo.zhucestatus!=1)%}
									<div class="col-md-2">
										<div id="uploader-demo">
											<div id="fileList" class="uploader-list"></div>
											<div id="sfzfmpic">选择图片</div>
										</div>
									</div>
									{%endif%}
									{% set sfzfmpic = userInfo.sfzfmpic | strToJson %}
									{% if( sfzfmpic.length > 0  )%}
									<a id="sfzfmpic-view" class="col-md-2 col-form-label" href="{{sfzfmpic[0]}}" data-toggle="lightbox">查看</a>
									{%else%}
									<a id="sfzfmpic-view" class="col-md-2 col-form-label" href="javascript:;" data-toggle="lightbox"></a>
									{%endif%}
								</div>
								<div class="form-group row align-items-center" {% if userInfo.org_type ==0 %} style="display: none;" {%endif%}> 
									<label class="required col-md-4 col-form-label">营业执照：</label>
									<input type="hidden" name="yyzzpic" class="form-control" required value="{{userInfo.yyzzpic}}" required/>
									{%if(userInfo.zhucestatus!=1)%}
									<div class="col-md-2">
										<div id="uploader-demo">
											<div id="fileList" class="uploader-list"></div>
											<div id="yyzzpic">选择图片</div>
										</div>
									</div>
									{%endif%}
									{% set yyzzpic = userInfo.yyzzpic | strToJson %}
									{% if( yyzzpic.length > 0  )%}
									<a id="yyzzpic-view" class="col-md-2 col-form-label" href="{{yyzzpic[0]}}" data-toggle="lightbox">查看</a>
									{%else%}
									<a id="yyzzpic-view" class="col-md-2 col-form-label" href="javascript:;" data-toggle="lightbox"></a>
									{%endif%}
								</div>
								<div class="form-group row align-items-center" {% if userInfo.org_type ==0 %} style="display: none;" {%endif%}>
									<label class="required col-md-4 col-form-label">开户许可证：</label>
									<input type="hidden" name="khxkzpic" class="form-control" required value="{{userInfo.khxkzpic}}" required/>
									{%if(userInfo.zhucestatus!=1)%}
									<div class="col-md-2">
										<div id="uploader-demo">
											<div id="fileList" class="uploader-list"></div>
											<div id="khxkzpic">选择图片</div>
										</div>
									</div>
									{%endif%}
									{% set khxkzpic = userInfo.khxkzpic | strToJson %}
									{% if( khxkzpic.length > 0  )%}
									<a id="khxkzpic-view" class="col-md-2 col-form-label" href="{{khxkzpic[0]}}" data-toggle="lightbox">查看</a>
									{%else%}
									<a id="khxkzpic-view" class="col-md-2 col-form-label" href="javascript:;" data-toggle="lightbox"></a>
									{%endif%}
								</div>
								<div class="form-group row">
									<label class="col-md-4 col-form-label"></label>
									{%if disable %} 
									<label class="col-md-4 col-form-label">已提交审核，请等待审核</label>
									{%else%}
									<div class="col-md-4 col-md-offset-2">
										<button class="btn btn-primary ajax-post confirm" target-form="form-renzheng"
											type="submit"><i class="fa fa-check"></i> {%if userInfo.zhucestatus == 2%}重新认证{%else%}认证{%endif%}</button>
									</div>
									{%endif%}
								</div>
							</form>
						</div>
					</div>
					<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
						<div class="row col justify-content-center align-items-center">
							<form class="form-password form-horizontal col-8" action="/center/seting/updatepassword" method="post" data-validate="parsley">
								<div class="form-group row">
									<label class="required col-md-4 col-form-label">旧密码：</label>
									<div class="col-md-4">
										<input type="password" class="form-control" name="oldpassword" placeholder="请输入旧密码" required>
									</div>
								</div>
								<div class="form-group row">
									<label class="required col-md-4 col-form-label">新密码：</label>
									<div class="col-md-4">
										<input type="password" class="form-control" name="password" placeholder="请输入新密码" required>
									</div>
								</div>
								<div class="form-group row">
									<label class="required col-md-4 col-form-label">确认密码：</label>
									<div class="col-md-4">
										<input type="password" class="form-control" name="repassword" placeholder="再次确认新密码" required>
									</div>
								</div>
								<div class="form-group row">
									<label class="col-md-4 col-form-label"></label>
									<div class="col-md-4 col-md-offset-2">
											<button class="btn btn-primary ajax-post no-refresh" target-form="form-password"
												type="submit"><i class="fa fa-check"></i> 确认修改 </button>
									</div>
								</div>
							</form>
						</div>

					</div>
				</div>
			</div>
		</div>



	</div>
</section>
<!-- / -->
{% endblock %}
{%block style%}
<link href="/static/assets/plugins/jquery-html5-upload/cropper/cropper.min.css" rel="stylesheet">
<link href="/static/assets/plugins/jquery-html5-upload/sitelogo/sitelogo.css" rel="stylesheet">
{%endblock%}
{% block script %}
<script src="/static/admin/js/webuploader/webuploader.js" type="text/javascript"></script>
<script type="text/javascript" src="/static/assets/js/view/demo.shop.js"></script>
<script src="/static/assets/plugins/jquery-html5-upload/cropper/cropper.min.js"></script>
<script src="/static/assets/plugins/jquery-html5-upload/sitelogo/sitelogo.js"></script>
<script>
	var imgList = {
		'avatar': '头像',
		'sfzzmpic': '身份证正面',
		'sfzfmpic': '身份证反面',
		'yyzzpic': '营业执照',
		'khxkzpic': '开户许可证'
	}
	for (var key in imgList) {
		if (imgList.hasOwnProperty(key)) {
			var element = imgList[key];
			var options = {

					// 选完文件后，是否自动上传。
					auto: true,

					// swf文件路径
					swf: '/static/admin/js/webuploader/Uploader.swf',

					// 文件接收服务端。
					server: '/ext/attachment/homefile/uploadpic?type=atlas',

					// 选择文件的按钮。可选。
					// 内部根据当前运行是创建，可能是input元素，也可能是flash.
					pick: {
						id: '#' + key,
						label: '选择图片'
					},
					// 只允许选择图片文件。
					accept: {
						title: 'Images',
						extensions: 'gif,jpg,jpeg,bmp,png',
						mimeTypes: 'image/*'
					}
				}
			if(key!='avatar')options.compress=false;
			var uploader = WebUploader.create(options);
			// 文件上传成功，给item添加成功class, 用样式标记上传成功。
			uploader.on( 'uploadSuccess', function( file,res ) {
				toastr.success(element+'上传成功');
				if(key=='avatar'){
					$('#'+key+'-view img').attr('src',res.src)
					//$('#'+key+'-view').attr('href',res.src)
				}else{
					$('#'+key+'-view').text('查看').attr('href',res.src)
				}				
				$('[name="'+key+'"]').val(JSON.stringify([res.src]))
			});

			// 文件上传失败，显示上传出错。
			uploader.on( 'uploadError', function( file ) {
				toastr.error(element+'上传失败');
			});

		}
	}
	$("input[name='org_type']").on("change",function () {
            var val = $(this).val();
            if(val == 1){
				$('[name="gsmc"]').attr("disabled",false).attr("required",true);
                $('[name="yyzzpic"]').attr("disabled",false).attr("required",true);
				$('[name="khxkzpic"]').attr("disabled",false).attr("required",true);
				$('[name="gsmc"]').parent().parent('.row').show();
				$('[name="yyzzpic"]').parent('.row').show();
				$('[name="khxkzpic"]').parent('.row').show();
            }else {
				$('[name="gsmc"]').attr("disabled",true).attr("required",false);
				$('[name="yyzzpic"]').attr("disabled",true).attr("required",false);
				$('[name="khxkzpic"]').attr("disabled",true).attr("required",false);
				$('[name="gsmc"]').parent().parent('.row').hide();
				$('[name="yyzzpic"]').parent('.row').hide();
				$('[name="khxkzpic"]').parent('.row').hide();
            }
        })
</script>
{% endblock %}